package com.chinamsp.codegen.convert.db.dto;

import com.chinamsp.codegen.convert.db.DbCodeGenUtils;

/**
 * 生成代码的属性
 * @author shifenghu
 *
 */
public class DBCodeGenProperty {

	/**
	 * 是否继承自父类
	 */
	private boolean extendParent;
	
	/**
	 * 注释
	 */
	private String comment;
	
	/**
	 * 数据库字段名称
	 */
	private String columnName;
	
	/**
	 * java 类型
	 */
	private Class<?> javaType;
	
	/**
	 * 属性名称
	 */
	private String name;
	
	/**
	 * 设置方法名称
	 */
	private String setterName;
	
	/**
	 * 获取方法的名称
	 */
	private String getterName;
	
	/**
	 * 数据库字段类型
	 */
	private String dbType;
	
	public DBCodeGenProperty(String columnName, String dbType, String comment) {
		this.columnName = columnName;
		this.dbType = dbType;
		// 转换 name 
		this.name = DbCodeGenUtils.fieldToProperty(columnName);
		this.comment = comment;
		this.javaType = DbCodeGenUtils.dbTypeCovertJavaType(dbType);
		this.setterName = DbCodeGenUtils.genSetterName(this.name);
		this.getterName = DbCodeGenUtils.genGetterName(this.name);
	}

	public boolean isExtendParent() {
		return extendParent;
	}

	public void setExtendParent(boolean extendParent) {
		this.extendParent = extendParent;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}
	

	public String getColumnName() {
		return columnName;
	}

	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	public String getJavaTypeName() {
		return javaType.getSimpleName();
	}


	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSetterName() {
		return setterName;
	}

	public void setSetterName(String setterName) {
		this.setterName = setterName;
	}

	public String getGetterName() {
		return getterName;
	}

	public void setGetterName(String getterName) {
		this.getterName = getterName;
	}

	public Class<?> getJavaType() {
		return javaType;
	}

	public void setJavaType(Class<?> javaType) {
		this.javaType = javaType;
	}
	

	public String getDbType() {
		return dbType;
	}

	public void setDbType(String dbType) {
		this.dbType = dbType;
	}

	@Override
	public String toString() {
		return "DBCodeGenProperty [extendParent=" + extendParent + ", comment=" + comment + ", column=" + columnName
				+ ", name=" + name + ", setterName=" + setterName + ", getterName="
				+ getterName + "]";
	}
	
	
}
